package com.exer1.servlet;

import com.exer1.pojo.Dormitory;
import com.exer1.service.DormitoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName DeleteDormitoryServlet
 * @Description 根据宿舍编号删除宿舍信息
 * @Author Kx
 * @Date 2025/4/24 0:12
 * @Version 1.0
 */
@WebServlet("/DeleteDormitoryServlet")
public class DeleteDormitoryServlet extends HttpServlet {

    // 实例化业务层对象
    private final DormitoryService dormitoryService = new DormitoryService();
    @Override
    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 获取请求参数
        String dormitoryId = req.getParameter("dormitoryId");

        // 转换成整型
        int id = Integer.parseInt(dormitoryId);

        dormitoryService.deleteDormitory(id);
    }
}
